package com.design.pattern.creational.prototype.clone;

import java.awt.print.Pageable;
import java.util.Date;

/**
 * description
 *
 * @author RenQiQiang 2019/03/31 15:18
 */
public class Test {
    public static void main(String[] args) throws CloneNotSupportedException {
        Date birthday = new Date(0L);

        Pig pig1 = new Pig("佩奇",birthday);
        Pig pig2 = (Pig) pig1.clone();
        System.out.println(pig1);
        System.out.println(pig2);

        pig1.getBirthday().setTime(666666666L);
        //重新设置完pig1之后 pig2也被修改了
        //因为里面的date 内存地址也是一样的
        //这里其实是浅克隆
        System.out.println(pig1);
        System.out.println(pig2);

    }
}
